home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
numzap.arc
/
NUMZAP.DOC
next >
Wrap
Text File
|
1985-10-18
|
20KB
|
897 lines
READ
THIS
BEFORE
PRINTING!!!!
This document has been formated in a special way. Virtually all dot
matrix printers have a condensed mode which prints 132 characters
across a standard 8 1/2 inch page. When this file is printed out in
condensed mode, the resulting printed pages can be cut down to 5 1/2 X
8 1/2 inches. The cut pages will fit nicely in the back of your
DOS manual for storage.
Typically, you can turn on this mode by sending a special control
sequence to the printer from BASIC. For example, you can turn on the
condensed mode of the IBM/Epson printer with the BASIC statement:
LPRINT chr$(15). If your printer has such a condensed mode, turn it
on now, before printing the rest of this document.
(tm)
NUMZAP
Selective Line Number Removing
Utility for the IBM Personal Computer
User's Manual
(c) 1983 by David Whitman
Version 1.00
David Whitman
136 Wellington Terrace
Lansdale, PA 19446
(215) 362-8526 (evenings)
(215) 641-7114 (days)
1
Table of Contents
I. What does NUMZAP do?..........................2
II. Programming with NUMZAP......................4
III. Running NUMZAP..............................5
IV. Using Converted Programs.....................7
V. Comments about Optimization...................8
VI. Miscellaneous and a Word From Our Sponsor....9
2
I. What does NUMZAP do?
NUMZAP is a utility for removing line numbers from BASIC
programs. Just removing the line number from the beginning of
each line is rather easy, and somewhat pointless. NUMZAP is
slightly more selective, however. NUMZAP removes only those line
numbers which are not referenced from other parts of the program.
For example, consider the following short BASIC program:
100 PRINT "Help me out of this loop!"
110 C$ = INKEY$: IF C$<>"" THEN STOP
120 GOTO 100
After passing through NUMZAP, the program will look like:
100 PRINT "Help me out of this loop!"
C$ = INKEY$: IF C$ <>"" THEN STOP
GOTO 100
You might think that this selective filtering is just as
pointless as removing *all* the line numbers. Certainly the
resulting file is not usable by the BASIC interpreter. The
reason for this particular conversion is to take advantage of a
little used feature of the IBM/Microsoft BASIC compiler. The
following is quoted from the BASIC compiler manual, page 42, in
the section on compiler parameters:
"/N The /N parameter tells the compiler to relax line
numbering constraints. When /N is specified, line
numbers in your source file may be in any order, or they
may be eliminated entirely. Any line numbers which exist
have nothing to do with the sequence of the lines; they
serve only as labels for GOSUBs, GOTOs, and any other
statements which use line numbers as references for
branching.
With /N, lines are compiled normally, but unnumbered
lines cannot be targets for GOTOs or GOSUBs."
3
" There are three advantages to using /N:
* Elimination of line numbers increases program
readability.
* The BASIC compiler optimizes over entire blocks of
code rather than single lines (for example in
FOR...NEXT loops).
* BASIC source code can more easily be included in a
program with $INCLUDE."
Another advantage, not mentioned in the manual, is that reducing
the number of numbered lines will enable the compiler to handle
larger source files. Since BASCOM only uses 64K regardless of
the actual memory available, remembering the offset of each line
number in a large program can soon eat up all the usable memory.
When this happens, BASCOM rather ungracefully begins to emit an
unending series of TC (Too Complex) error messages until it
reaches the end of your program.
NUMZAP, then, is a utility to allow effective use of BASCOM's /N
parameter. When programs are passed through NUMZAP prior to
compilation, BASCOM can do a better job of optimizing the
resulting object code. The object code produced tends to be
tighter, more compact, and faster running. As an added bonus,
since fewer line numbers need to be remembered, larger programs
can be compiled.
4
II. Programming With NUMZAP
There are four steps to producing an optimized BASIC program with
NUMZAP:
1. Enter the program using the BASIC interpreter's screen
editor.
2. Run and debug the program from within the interpreter.
3. Pass the debugged program through NUMZAP.
4. Compile the 'zapped program with BASCOM, using the /N
parameter.
5. Link the compiled program with LINK.
It is assumed that users are familiar with steps 1,2 and 5. Steps
3 and 4 will be covered in the following sections.
5
III. Running NUMZAP
Your program must be in ASCII format or NUMZAP will be unable to
read it. This means that you must use the "A" option when saving
the program from BASIC:
SAVE"myprog.bas",A
There are two ways to start up NUMZAP:
1. Prompt mode:
From DOS, type:
NUMZAP
After a few seconds, NUMZAP prints a hello screen, then
prompts:
Input file name? [.bas]
Type in the name of the program you want converted. If you
don't provide an extension, NUMZAP assumes it to be .BAS. If
NUMZAP is unable to find the file, you will be given the
option of naming another file, or returning to DOS. The same
options will be presented to you if NUMZAP discovers that the
file is not in ASCII mode.
Once the input file has been specified, NUMZAP will prompt:
Output file name? [.zap]
Type in a name for the converted program. If you just press
enter, the name defaults to that of the input file, with an
extension of .ZAP.
NUMZAP will now convert your program. Two passes are made
over the program. On the first pass, NUMZAP builds a table of
all the referenced line numbers. On the second pass, the
converted program is built.
6
During the conversion process, a status line is maintained on
the screen, letting you know how much progress has been made.
You may abort and return to DOS at any time by pressing the
Esc key.
When finished, NUMZAP returns you to DOS, and you see the
prompt:
A>
2. Expert mode:
You can specify the input and output filenames when you invoke
NUMZAP. The syntax is:
NUMZAP [inputname[.ext]] [outputname]
The defaults are as under prompt mode. If you leave off the
extension on the input filename, NUMZAP assumes it to be .BAS.
If you don't provide the output filename, it will default to
the input name with a .ZAP extension. If there are any
problems with the input file, NUMZAP will dump you out to
prompt mode.
7
IV. Using Converted Programs
You must use the /N option when compiling programs converted
with NUMZAP. Thus, to compile MYPROG.ZAP you would type:
BASCOM myprog.zap /n;
or (Prompts upper case, your responses in lower case):
bascom
SOURCE FILENAME [.BAS]: myprog.zap /n
OBJECT FILENAME [MYPROG.OBJ]: <return>
SOURCE LISTING [NUL.LST]: <return>
If you forget to specify the /N, BASCOM will deluge you with
error messages. Unlike other, more friendly programs, there
is no way to abort compilation once started. Just sit through
the messages and try again.
Hang onto your un'zapped source file! Zapped programs can NOT
be read by the BASIC interpreter (you'll get a "Direct
statement in File" message). If you intend to do any further
debugging under the interpreter, don't erase your source file.
A rudimentary renumbering utility is provided on your NUMZAP
disk, but don't depend on RENUM if you do extensive editing of
the 'zapped file. RENUM simply adds line numbers
sequentially, with a step size of one. If you add too many
new lines, there won't be enough line numbers to use between
the existing numbers.
If this happens, RENUM will abort with a "Fatal Error"
message. Your only recourse should this happen is to split
the file at the point where the Fatal Error occurred, and
renumber the parts separately. The moral of all this is to do
your editing on the original BAS file, and use ZAP files
for compilation only.
8
V. Comments About Optimization
In general, programs passed through NUMZAP prior to
compilation will be both smaller and faster running. The
magnitude of these effects will vary from program to program.
As a rule, the larger the program, the more noticable will
the the reduction in size. This is because all compiled
BASIC programs have a constant size contribution from the
various run-time routines which are either linked in, or are
a part of BASRUN.EXE.
It turns out that the smallest compiled BASIC program will
take up almost 20K, the size of the run-time enviroment. If
you have a 22K compiled program, the *percent* change in size
after using NUMZAP is not going to be very big, since most of
the size is the invarient run-time stuff which NUMZAP can't
affect. Larger programs, in which more of the size is
actually caused by the code you write, will show more
noticable shrinkage, even though the decrease in size per
line is about the same.
The increase in speed noted will depend on just what the
program *does*. Programs which do a lot of number crunching,
or screen handling, will show the greatest improvements.
On the other hand, programs which do a lot of disk access
will show little if any speed enhancement. These programs
are "I/O bound" - the program is kill System Requirements:
NUMZAP requires 64K of memory, and at least one disk
drive. Obviously, BASCOM is required for the program to
have any utility.
B. Programming Notes:
NUMZAP was written in BASIC, and passed through itself
prior to compilation. The source code for NUMZAP is
distributed along with the compiled version, in case
you'd care to customize. I would appreciate hearing
System Requirements:
NUMZAP requires 64K of memory, and at least one disk
drive. Obviously, BASCOM is required for the program to
have any utility.
B. Programming Notes:
NUMZAP was written in BASIC, and passed through itself
prior to compilation. The source code for NUMZAP is
distributed along with the compiled version, in case
you'd care to customize. I would appreciate hearing
about any improvements people make, for possible
inclusion in future releases.
If you attempt to modify NUMZAP, you should be aware that
the machine language subroutine which reads the DOS
command line to handle "expert mode" is incompatible with
the BASIC interpreter. If you attempt to run NUMZAP's
source code under the interpreter without disabling this
subroutine, a system crash will result, and you'll have
to reboot. This routine only gets called once, and I
generally convert the call into a comment while debugging
with the interpreter.
C. Red Tape and Legal Nonsense:
1. Disclaimer:
NUMZAP is distributed as is, with no guarantee that it
will work correctly in all situations. In no event
will the Author be liable for any damages, including
lost profits, lost savings or other incidental or
consequential damages arising out of the use of or
inability to use this program, even if the Author has
been advised of the possibility of such damages, or
for any claim by any other party.
Despite the somewhat imposing statement above, it *is*
my intention to fix any bugs which are brought to my
attention. Drop me a line if you think you've found a
problem.
10
2. Copyright Information:
The entire NUMZAP distribution package, consisting of
source, object, and documentation files, is copyright
(c) 1983 by David Whitman. The author reserves the
exclusive right to distribute this package, or any
part therof, for profit. The name NUMZAP (tm) applied
to a microcomputer programming utility is a trademark
of David Whitman.
This package may be copied freely by individuals for
evaluation purposes. It is expected that those who
find the package useful will make a contribution
directly to the author of the program, regardless of
where they obtained their copy.
D. Tanstaafl (i.e. There Ain't No Such Thing As a Free Lunch)
CHASM is distributed under the Freeware marketing scheme,
developed by Andrew Fluegelman, whose efforts are
gratefully acknowleged.
Anyone may obtain a free copy of this program by sending a
blank, formatted diskette to the author. An addressed,
postage-paid return mailer must accompany the disk (no
exceptions, please).
A copy of the program, with documentation, will be sent by
return mail. The program will carry a notice suggesting a
contribution to the program's author. Making a
contribution is totally voluntary on the part of the
users. Regardless of whether a contribution is made, the
user is encouraged to share the program with others.
Payment for use is discretionary on the part of each
subsequent user.
11
The underlying philosophy here is based on three
principles:
First, that the value and utility of software is best
assessed by the user on his/her own system. Only
after using a program can one really determine
whether it serves personal applications, needs, and
tastes.
Second, that the creation of independent personal
computer software can and *should* be supported by
the computing community.
Finally, that copying and networking of programs should
be encouraged, rather than restricted. The ease with
which software can be distributed outside traditional
commercial channels reflects the strength, rather
than the weakness, of electronic information.
If you like this way of distributing software, please support it.
Send a contribution, and tell your friends and collegues about
software you find useful. Write to the editor of your favorite
computer magazine and tell *him* (or *her*) also. Only with your
support can authors of programs such as this continue to provide
quality software under a system so favorable to YOU, the user.
David Whitman
136 Wellington Terrace
Lansdale, PA 19446
(215) 641-7114
12
==============Also Available===============
CHASM is a full featured assembler for the IBM personal computer.
Much simpler than the IBM Macro Assembler, CHASM is well suited
for learning assembly language, as well as for production coding.
Programs assembled by CHASM do not require linking, and are
already in the fast loading COM format produced by the DOS
utility EXE2BIN. This design decision eliminates two "hidden"
steps involved in producing a running program with the Macro
Assembler.
CHASM supports two distinct, simple ways to get machine language
subroutines into programs written in BASIC, the most popular
language for the IBM personal computer. (The only way to use the
Macro Assembler with BASIC is long, convoluted and confusing.)
CHASM comes complete with sixty pages of documentation, plus
a twenty page primer which introduces assembly language for total
beginners.
CHASM is available in two forms, an interpreted version and a
compiled version. The interpreted version is available free of
charge for evaluation. Those who find the program useful are
requested to make a contribution to the author. A compiled
version, which runs about 6 times faster, is available as a free
upgrade to those who make a contribution of $30 or more.
To obtain a copy of CHASM, send a blank, formatted diskette, plus
a stamped return mailer (no exceptions, please) to:
David Whitman
136 Wellington Terrace
Lansdale, PA 19446
If you would prefer to directly receive the compiled version,
enclose a check for $30 with your disk.